{include file="public/layout" /}
<body>
  <div class="layui-fluid">
      <div class="layui-row layui-col-space15">
          <div class="layui-col-md12">
            <div class="layui-card">
              <div class="layui-card-body" pad15>
                <div class="layui-form" wid100 lay-filter="">
                  <div class="layui-form-item sort-list">
                      {volist name='$menuList' id='vo'}
                      <div class="fl">
                        <input type="checkbox" lay-skin="primary" name="checkedids[]" value="{$vo.id}" title="{$vo.title}" data-ids="{$vo.id}" {if condition="$vo.checked"}checked{/if}>
                      </div>
                      {/volist}
                  </div>
                  <div class="layui-form-item">
                      <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
                  </div>
              </div>
            </div>
          </div>
        </div>
      </div>
  </div>

  <script>
  layui.config({
    base: '__SKIN__/' //静态资源所在路径
    ,version: '{$version}'
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'set'], function(){
    var $ = layui.$
    ,layer = layui.layer
    ,form = layui.form;

    /** 拖动排序相关 js*/
    $( ".sort-list" ).sortable({
        start: function( event, ui) {

        }
        ,stop: function( event, ui ) {

        }
    });
    $( ".sort-list" ).disableSelection();

    //监听提交
    form.on('submit(formSubmit)', function(data){
        var load = layer_loading();
        data.field._ajax = 1;

        var ids = [];
        $("input[name^=checkedids]").each(function(index, item){
            ids.push($(item).data('ids'));
        })
        data.field.ids = ids;

        $.ajax({
            type : 'post',
            url : "{:url('Index/ajax_quickmenu')}",
            data : data.field,
            dataType : 'json',
            success : function(res){
                layer.close(load); //关闭loading
                if(res.code == 1){
                    layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                        parent.gourl(res.url);
                    });
                }else{
                    showErrorMsg(res.msg);
                }
            },
            error: function(e){
                layer.close(load); //关闭loading
                showErrorAlert();
            }
        });
        return false;
    });

  });

  </script>
{include file="public/footer" /}